var db    = {};
var mysql = require('mysql');
var pool  = mysql.createPool({
  connectionLimit : 10,
  host:'47.110.126.134',
  user:'api_book',
  password:'root',
  port:'3306',
  database:'api_book',
  // connectTimeout:5000,//连接超时
  multipleStatements:false,//是否允许一个query中包含多条sql语句
});
 
db.query = function(sql, callback){
	if (!sql) {
		callback();
		return;
	}
	pool.query(sql, function(err, results, fields) {
	  if (err) {
	    console.log(err);
	    callback(err, null);
	    return;
	  };
 
	  callback(null, results, fields);
	});
}
module.exports = db;
